package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * @author xingjishuai
 * @date 2024-07-30
 */
@Getter
public enum AuditStatusEnums {
    SUBMITTED(0, "待提交"),
    AUDIT(1, "审核中"),
    AUDIT_SUCCESS(2, "审核成功"),
    AUDIT_REJECT(3, "审核驳回"),
    AUDIT_REVOCATION(4, "撤回");
    private final Integer type;
    private final String value;

    AuditStatusEnums(int type, String value) {
        this.type = type;
        this.value = value;
    }


    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(Integer type) {
        for (AuditStatusEnums status : AuditStatusEnums.values()) {
            if (type == (status.getType())) {
                return status.getValue();
            }
        }
        return null;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static Integer getTypeByDesc(String description) {
        for (AuditStatusEnums status : AuditStatusEnums.values()) {
            if (description.equalsIgnoreCase(status.getValue())) {
                return status.getType();
            }
        }
        return null;
    }
}
